package network.course2.com.youkeda;

import com.alibaba.fastjson.JSON;
import network.course2.com.youkeda.model.Apartment;

import java.util.Map;


public class ObjectPrinter {
    public static void main(String[] args) {
        Apartment a = new Apartment();
        a.setName("研究生公寓");
        a.setAddress("杭州市江干区学林街628号");
        a.setTotalRooms(54);
        a.setBuiltupArea("380平米");
        System.out.println(a);
        String content = JSON.toJSONString(a);
        Apartment apartment = JSON.parseObject(content, Apartment.class);
        System.out.println("Apartment2对象建筑面积=" + apartment.getBuiltupArea());
        //反序列化为Map对象
        Map ainfo = JSON.parseObject(content, Map.class);
        String adress = (String) ainfo.get("address");
        System.out.println("Map.address的值=" + adress);

    }
}
